function reallocProductType(p,n,q)
  use derived,only:ProductType
  use react_data_param,only:react_type
  implicit none

  type(ProductType),pointer,dimension(:) :: &
       reallocProductType,p
  integer,intent(in) :: n,q

  integer :: i,j,nn,ierr

  allocate(reallocProductType(1:n),stat=ierr)
  if (ierr.ne.0) call abnormal_stop("reallocProductType",&
       "Memory allocation causes an error.")

  do i=1,n
     nullify(reallocProductType(i)%prod_type)
  end do

  if (.not.associated(p)) return

  do i=1,n-1
     nn=react_type(q)%n_new(i)
     if (nn.gt.0) then
        allocate(reallocProductType(i)%prod_type(nn))
        do j=1,nn
           reallocProductType(i)%prod_type(j)=&
                p(i)%prod_type(j)
        end do
        deallocate(p(i)%prod_type)
     end if
  end do

  deallocate(p)

  return

end function reallocProductType
